#pragma once

#include <QGraphicsItem>

using namespace std;
class Node;
class Title;
class Path;
class mainClass;
class QGraphicsSceneMouseEvent;
class SceneView;

class Sensor : public QObject, public QGraphicsItem
{
	Q_OBJECT

public:
	Sensor(SceneView *_parentScene, Path *_sourcePath, double _percentPos, bool _visibleTitle = true,
		double _as = 0, double _ad = 0, double _ms = 0, double _md = 0);
	Sensor();
	QRectF boundingRect() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void addTitle(Title *_title);
	void setEnabled(bool b){ enable = b; title->setEnabled(b);	title->update(); }
	bool enabled(){	return enable; }
	void setAccepted(bool b){ accepted = b; }
	void adjust();
	void initModel();
	void setSelectrable(bool s);
	Title *title;
	Path *source;
	double percentPos;
	TreeModel* model;
	double additive_stochastic, additive_deterministic; 
	double multiplicative_stochastic, multiplicative_deterministic;
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *event);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
	QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
	SceneView *parentScene;
	bool enable;
	bool accepted;
	QRectF size;
	bool visibleTitle, visibleValue;
private slots:
	void getModelData(QString name, double _percentPos, bool dispTitle, bool dispValue,
		double _additive_stochastic = 0, double _additive_deterministic = 0, 
		double _multiplicative_stochastic = 0, double _multiplicative_deterministic = 0);
	void updateTree();
signals:
	void setModelData(QString name, double _percentPos, bool dispTitle, bool dispValue,
		double _additive_stochastic = 0, double _additive_deterministic = 0, 
		double _multiplicative_stochastic = 0, double _multiplicative_deterministic = 0);

};
